﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AAA.Meta.Quote.Data
{
    public class SortItem : IComparable
    {
        public const int ASC = 1;
        public const int DESC = -1;

        private string _strItemName;

        public string ItemName
        {
            get { return _strItemName; }
            set { _strItemName = value; }
        }

        private int _iOrderDirection;

        public int OrderDirection
        {
            get { return _iOrderDirection; }
            set { _iOrderDirection = value; }
        }

        public SortItem(string strItemName) : this(strItemName, ASC) { }

        public SortItem(string strItemName, int iOrderDirection)
        {
            _strItemName = strItemName;
            _iOrderDirection = iOrderDirection;
        }

        #region IComparable 成員

        public int CompareTo(object obj)
        {
            return ItemName == null || (obj == null)
                        ? 0
                        : ((SortItem)obj).ItemName == null
                            ? 0
                            : ItemName.CompareTo(((SortItem)obj).ItemName);
        }

        #endregion
    }
}
